/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.purpose.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.koron.purpose.domain.PurposeItem;

public interface PurposeItemMapper {
	
	@Insert("insert into purpose_item(id,add_user,add_user_name,add_time,update_user,update_user_name,"
			+ "update_time,item_id,item_name,item_value,rule,note,negatively,purpose_contract_id) "
			+ "values (#{id},#{addUser},#{addUserName},#{upadteUser},#{updateUserName},#{updateUserName},"
			+ "#{updateTime},#{itemId},#{itemName},#{itemValue},#{rule},#{note},#{negatively},#{purposeContractId})")
	Integer insert(PurposeItem item); 	
	
	@Insert("<script>"
			+ "insert into purpose_item(id,add_user,add_user_name,add_time,update_user,update_user_name,"
			+ "update_time,item_id,item_name,item_value,rule,note,negatively,purpose_contract_id) values"
			+ "<foreach collection ='beanList' item='item' index='index' separator =','>"
			+ "(#{item.id},#{item.addUser},#{item.addUserName},#{item.addTime},#{item.updateUser},#{item.updateUserName},"
			+ "#{item.updateTime},#{item.itemId},#{item.itemName},#{item.itemValue},#{item.rule},#{item.note},#{item.negatively},#{item.purposeContractId})"
			+ "</foreach>"
			+ "</script>")
	Integer batchInsert(@Param("beanList") List<PurposeItem> list);
	
	@Delete("delete from purpose_item where purpose_contract_id=#{id}")
	Integer deleteByContractId(@Param("id") String id);
	
	@Select("select * from purpose_item where purpose_contract_id=#{id}")
	List<PurposeItem> queryByContractId(@Param("id") String id);
	
}
